var _tools = require("../../utils/tools");
var app = getApp(), page = app.page, request = app.util.request, route = app.route, toast = app.toast;

page({
  data: {
    curr: 0,
    search_value: '',
    type: [],
    lists: [],
    isLoad:true
  },
  onLoad: function (t) {
    var _this = this;
    request({
      url: "ContractType",
      showLoading: !1,
      success: function (t) {
        t = [{
          title: "全部",
          id: -1
        }].concat(t);
        _this.setData({
          type: t
        })
        _this.getContractList();
      }
    });
  },
  getContractList() {
    var _this = this;
    request({
      url: "ContractList",
      data: {
        title: _this.data.search_value,
        type_id: _this.data.type[_this.data.curr].id,
        number: 20,
        page: _this.data.lists.length
      },
      success: function (t) {
        wx.stopPullDownRefresh();
        if (t.length > 0) {
          var lists = _this.data.lists.concat(t)
          _this.setData({
            isLoad:false,
            lists: lists
          })
        }
      }
    });
  },
  input: function (a) {
    this.setData({
      search_value: a.detail.value
    })
  },
  search: function () {
    var _this = this;
    _this.setData({
      lists: [],
    });
    _this.getContractList();
  },
  goDetail: function (e) {
    wx.navigateTo({
      url: './detail?id=' + e.currentTarget.dataset.id,
    })
  },
  chooseNav: function (t) {
    t = t.currentTarget.dataset.index;
    this.setData({
      curr: t,
    })

  },
  swiperChange: function (t) {
    t = parseInt(t.detail.current);
    this.setData({
      curr: t,
      lists: []
    })
    this.getContractList();
  },
  reachBottom: function () {
    var _this = this;
    _this.getContractList();
  },
  pullDownRefresh: function () {
    this.setData({
      lists: []
    })
    this.getContractList();
  },
});